const url = "http://175.178.10.3:457/api/hook/1701766386775/1701852338553";

const fetch = require("node-fetch");

async function main() {
  console.log("Is publishing……");
  console.time("publish use time");
  try {
    let response = await fetch(url, {
      method: "GET",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
      },
    });
    let ret = await response.json();
    if (ret.msg == "ok" && ret.data) {
      let tmp =
        ret.data.indexOf("Fast-forward") != -1 &&
        ret.data.indexOf("Aborting") == -1
          ? "Success ✓"
          : "Fail X";
      let arr = ret.data.split("\r\n");
      arr.forEach((t) => console.log(t));
      console.log("Result：", tmp);
    } else {
      console.log(ret);
    }
  } catch (e) {
    console.log(e);
  }
  console.log("Publish complete");
  console.timeEnd("publish use time");
}
main();
